package day10;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

class MyCallable2 implements Callable<Integer> {
    private int a;
    private int b;
    private int c;

    public MyCallable2(int a, int b, int c) {
        this.a = a;
        this.b = b;
        this.c = c;
    }

    public int getA() {
        return a;
    }

    public void setA(int a) {
        this.a = a;
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        this.b = b;
    }

    public int getC() {
        return c;
    }

    public void setC(int c) {
        this.c = c;
    }

    @Override
    public Integer call() throws Exception {
        int n = Max();
        return n;
    }

    private int Max(){
        int max = a;
        if (max < b) max = b;
        if (max < c) max = c;
        return max;
    }

}

/*
 * 10! 8! 5!的阶乘
 */
public class CallableDemo2 {
    public static void main(String[] args) throws InterruptedException, ExecutionException {
        //创建阶乘对象的实例
        MyCallable2 m = new MyCallable2(21, 9, 15);

        //包装计算阶乘的任务对象
        FutureTask<Integer> ft = new FutureTask<Integer>(m);

        //创建线程对象
        Thread t = new Thread(ft);

        //启动线程
        t.start();

        //返回打印的结果
        System.out.println("最大值为 ：" + ft.get());


    }
}